package com.example.hotsearchplatform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.hotsearchplatform.dto.HotSearchForward5DTO;
import com.example.hotsearchplatform.pojo.entity.Information;
import com.example.hotsearchplatform.vo.InfoLookVO;
import com.example.hotsearchplatform.vo.searchCountVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface InformationMapper extends BaseMapper<Information> {



    @Select("SELECT platform, SUM(search_num) AS searchNum\n" +
            "FROM (\n" +
            "         SELECT\n" +
//            "             platform,\n" +
            "             search_num,\n" +
            "             ROW_NUMBER() OVER (PARTITION BY platform ORDER BY search_num DESC) AS rn\n" +
            "         FROM information\n" +
            "         WHERE platform IN ('微博', '抖音', '快手', '百度', '知乎')\n" +
            "     ) subquery\n" +
            "WHERE subquery.rn <= 5\n" +
            "GROUP BY platform\n" +
            "ORDER BY FIELD(platform, '微博', '抖音', '快手', '百度', '知乎');")
    @Results({
//            @Result(property = "platform", column = "platform"),
            @Result(property = "searchNum", column = "searchNum")
    })
    List<HotSearchForward5DTO> selectTop5SearchNum();




    List<InfoLookVO> getLookTop10();
}
